var express = require('express')
var router = express.Router()

// 导入控制器模块
const IndexController = require('../controller/IndexController.js')
const categoryController = require('../controller/categoryController.js')
const articleController = require('../controller/articleController.js')
const UserController = require('../controller/UserController.js')
const systemController = require('../controller/systemController.js')
const query = require('../model/query.js')
const multer = require('multer')
const upload = multer({
    dest: './uploads/'
})
// 后台首页
router.get('/', IndexController.index)

router.get('/systemData', IndexController.systemData)
// 展示分类列表页面
router.get('/category', categoryController.index)
router.get('/article', articleController.index)
// 后台登录页
router.get('/login', IndexController.login)
router.get('/test', IndexController.test)
router.get('/apiData', IndexController.apiData)
// 文章列表数据接口
router.get('/article',articleController.index)

router.get('/artData', articleController.artData)
router.get('/editArt', articleController.editArt)
// 分类列表数据接口
router.get('/cateData', categoryController.cateData)

// 编辑分类的接口  
router.post('/updCateData', categoryController.updCateData)

// 删除分类数据接口
router.post('/deleteCate', categoryController.deleteCate)
// 数据图
router.get('/cateCount', categoryController.cateCount)

// 登录接口
router.post('/userLogin',UserController.userLogin)

// 登出接口
router.post('/userLogout',UserController.userLogout)
// 更新用户信息
router.post('/updUserInfo',UserController.updUserInfo)
// 更换头像
router.post('/avatar', upload.single('file'), UserController.avatar)
//更新密码
router.post('/updatePassword',UserController.updatePassword)

// 删除文章接口
router.post('/delArtData', articleController.delArtData)

// 展示添加文章的页面
router.get('/addArticle', articleController.addArticle)
router.get('/addCategory',categoryController.addCategory)
// 添加文章的接口
router.post('/addArtData', upload.single('photo'), articleController.addArtData)

router.post('/addCateDate',categoryController.addCateDate)
// 获取单条数据的接口
router.get('/fetchOneArt',articleController.fetchOneArt)

// 编辑文章接口
router.post('/updArtData',upload.single('photo'),articleController.updArtData)

router.get('/system',systemController.system)
// 编辑系统
router.post('/updSystemData',systemController.updSystemData)
module.exports = router;